
#include <view/Controle.h>




///////////////////

Controle::Controle(int cx, int cy, int x, int y)
{
    m_bFixo    = true;
    m_bVisivel = true;
    m_parent   = NULL;
    m_xPos     = x;
    m_yPos     = y;
    m_uLargura = cx;
    m_uAltura  = cy;
    m_xPivo    = 0;
    m_yPivo    = 0;
    m_alpha    = 0;
    m_angulo   = 0.0;
    
    m_pContexto = new MatrizRGBA(cx, cy);
    
    m_janela = NULL;
}

Controle::~Controle()
{
    ;
}




void Controle::AdicionarControle(Controle* c)
{
    m_listaCtrl.push_back(c);
    
    c->m_hwnd   = this->m_hwnd;
    c->m_janela = this->m_janela;
    c->m_parent = this;
    
//    this->Redesenhar(c);
}


unsigned short Controle::PosicaoAbsolutaX()
{
    Controle* c = this;
    int x=0;

    while(c)
    {
        x += c->PosicaoX();
        c = c->m_parent;
    }

    return x;
}


unsigned short Controle::PosicaoAbsolutaY()
{
    Controle* c = this;
    int y=0;

    while(c)
    {
        y += c->PosicaoY();
        c = c->m_parent;
    }

    return y;
}


void Controle::Largura(int cx)
{
    Matriz().Redimensionar(cx, Altura());
    m_uLargura = cx;
}

void Controle::Altura(int cy)
{
    Matriz().Redimensionar(Largura(), cy);
    m_uAltura = cy;
}

void Controle::Fixo(bool bFixo)
{
    m_bFixo = bFixo;
}

bool Controle::Fixo()
{
    return m_bFixo;
}

void Controle::Alpha(unsigned char alpha)
{
    m_alpha = alpha;
}

unsigned char Controle::Alpha()
{
    return m_alpha;
}

void Controle::Visivel(bool bVisivel)
{
    m_bVisivel = bVisivel;
    
}

bool Controle::Visivel()
{
    return m_bVisivel;
}

void Controle::PosicaoAbsoluta(unsigned short xPos, unsigned short yPos)
{
    m_xPos = xPos;
    m_yPos = yPos;
}

void Controle::Deslocar(int xDelta, int yDelta)
{
    m_xPos += xDelta;
    m_yPos += yDelta;
}

void Controle::PosicaoX(int x)
{
    m_xPos = x;
}

void Controle::PosicaoY(int y)
{
    m_yPos = y;
}

void Controle::Angulo(double angulo)
{
    m_angulo = angulo;
}

double Controle::Angulo()
{
    return m_angulo;
}
